package com.guonl.controller;

import com.guonl.service.user.UserService;
import com.guonl.model.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by Administrator on 2017/8/16.
 */
@Api(description = "用户模块")
@Controller
@RequestMapping(value = "/user")
public class UserController {

    @Autowired
    private UserService userService;

    @ResponseBody
    @ApiOperation("添加用户")
    @RequestMapping(value = "/add", method = RequestMethod.POST, produces = {"application/json;charset=UTF-8"})
    public int addUser(User user){
        return userService.addUser(user);
    }

    @ApiOperation("查询所有用户")
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public Object findAllUser(int pageNum, int pageSize){

        return userService.findAllUser(pageNum,pageSize);
    }
}
